<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of LoginModel
 *
 * @author Administrator
 */

namespace app\model;

use think\Model;

class Catgory extends Model {

    //put your code here
    // 设置字段信息

    public function tree($data,$pid=0,$level=0) {
//      $data = $this->find();
        static $arr= array();
    
        foreach( $data as $k => $v){
            if($v['parent_id']==$pid){
               $v['level']=$level;
               $v['split']= str_repeat("---", $level);
               $arr[]=$v;
               $this->tree($data,$v['id'],$level+1);
            }
        }
        return $arr;
    }

}
